$(function() {
	
	var slideDown = function(){
		var len = $(".regularSelect_opt").length;
		$(".regularSelect_opts").css({
			"display":"block",
			"height":"0px"
		}).stop().animate({
			"height" : "" + len*20
		}, 200, function(){
			$this.addClass("expanded");
		});
	};
	
	var slideUp = function(){
		$(".regularSelect_opts").stop().animate({
			"height" : "0px"
		}, 200, function(){
			$(".regularSelect_opts").css({
				"display":"none"
			});
			$(".regularSelect_sel").removeClass("expanded");
		});
	};
	
	$(".regularSelect_sel").click(function() {
		$this = $(this);
		if(!$this.hasClass("expanded")){
			slideDown();
		}else{
			slideUp();
		}
		return false;
	});
	
	$(".regularSelect_opt").click(function() {
		$(".regularSelect_sel>span").html($(this).html());
		
		slideUp();
		
		return false;
	});

	$("body").click(function() {
		slideUp();
	});
});